/*
    This file is part of SQLiteGTK, written by Aly Hirani

    SQLiteGTK is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.

    SQLiteGTK is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with SQLiteGTK.  If not, see <http://www.gnu.org/licenses/>.
*/

#include "main.h"
#include "main_window.h"
#include "util.h"
#include "include.h"
#include "opt_manager.h"

/**
 * The main entry point of the program. argv is analyzed for the startup arguments,
 * which can be of the form --sql file1 --sql file2 db.
 * @note See --help for more on the format of the arguments
 */
int
main (int argc, char *argv[])
{	
	gtk_init(&argc, &argv);
	
	init_app();
	
	if(argc == 1)
	{
		main_window_create(NULL, NULL);
	}
	else
	{
		GList *sql_list = NULL;
		OptManagerOptionGroup *opt_group = NULL;
		OptManagerOption opt_sql = {"s", "sql", TRUE, FALSE, NULL, NULL};
		OptManagerOption opt_db = {"db", "database", TRUE, TRUE, NULL, NULL};

		opt_group = opt_manager_option_group_new();

		opt_sql.user_data = opt_db.user_data = &sql_list;

		opt_manager_option_group_add_option(opt_group, &opt_sql);
		opt_manager_option_group_add_option(opt_group, &opt_db);
	}
	
	gtk_main();
	
	uninit_app();
	
	return 0;
}
